{% extends 'layout/basic.html' %}
{% load static %}

{% block title %}
    用户登录
{% endblock %}


{% block css %}
    <link rel="stylesheet" href="{% static 'css/account.css' %}">
{% endblock %}


{% block content %}
    <div class="container">
        <form id="id_form" class="form-horizontal" method="post" action="{% url 'app01:login' %}" novalidate>
            {% csrf_token %}
            <div class="account">
                <div class="form-group">
                    <div class="col-sm-offset-5 col-sm-6">
                        <h2>用户登录</h2>
                    </div>
                </div>

                {% for field in obj %}
                    {% if field.name == 'code' %}
                        <div class="form-group">
                            <label for='{{ field.id_for_label }}'
                                   class="col-sm-3 control-label">{{ field.label }}</label>
                            <div class="col-sm-9">
                                <div class="col-sm-7" style="padding-left: 0;padding-right: 0;">
                                    {{ field }}
                                    <span class="errors">{{ field.errors.0 }}</span>
                                </div>
                                <div class="col-sm-5">
                                    <img id="id_img" src="{% url 'app01:image' %}">
                                </div>
                            </div>
                        </div>
                    {% else %}
                        <div class="form-group">
                            <label for='{{ field.id_for_label }}'
                                   class="col-sm-3 control-label">{{ field.label }}</label>
                            <div class="col-sm-9">
                                {{ field }}
                                <span class="errors" >{{ field.errors.0 }}</span>
                            </div>
                        </div>
                    {% endif %}
                {% endfor %}
                <div class="form-group">
                    <div class="col-sm-offset-3 col-sm-9">
                        <input type="submit" class="btn btn-primary btn-lg" value="登 录"></input>
                        <div style="float: right">
                            <a href="{% url 'app01:login_sms' %}">手机验证码登录?</a>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
{% endblock %}


{% block js %}
    <script>
        $('#id_img').click(function () {
            var src_path = $(this).attr('src');
            $(this).attr('src', src_path+'?')
        })
    </script>
{% endblock %}

